<?php
/*
 * @Author: your name
 * @Date: 2022-01-11 16:41:20
 * @LastEditTime: 2022-01-11 17:19:40
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \www.wy.com\app\admin\validate\AdminUser.php
 */
declare(strict_types = 1);

namespace app\admin\validate;

use think\Validate;

class AdminUserValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'username|用户名' => 'require',
        'password|密码' => 'require',
        'captcha|验证码' => 'require|captcha'
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
        'username.require' => '管理员名称不能为空哦！',
        'password.require' => '密码不能为空哦！',
        'captcha.require' => '验证码不可以空哦！',
        'captcha.captcha' => '验证码错误！'
    ];

    // 登录验证场景
    public function sceneAdminUser()
    {
        return $this->only(['username','password','captcha']);
    }
}
